<?php
namespace App\Http\Controllers\ShopApi\V1\CommentManager;

use App\Http\Controllers\ShopApiController;
use App\Http\Controllers\Business\Shop\V1\CommentManagement\CommentManagement;
use App\Models\Comment;

class CommentManagerController extends ShopApiController
{
    //评论列表
    public function commentList() {
        $shopId = $this->request->get('shopid');
        if($this->request->has('type')) {
            $type = $this->request->get('type');
        } else {
            $type = 'all';
        }
        if($this->request->has('page')) {
            $page = $this->request->get('page');
        } else {
            $page = 1;
        }
        if($this->request->has('length')) {
            $length = $this->request->get('length');
        } else {
            $length = 20;
        }
        $result = CommentManagement::commentList($shopId, $type, $page, $length);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        } else {
            return $this->responseSuccessData($result['data']);
        }
    }
    //回复评论
    public function replyComment() {
        $shopId = $this->request->get('shopid');
        $commentId = $this->request->get('commentid');
        $replyContent = $this->request->get('replycontent');
        $result = CommentManagement::replyComment($shopId, $commentId, $replyContent);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        } else {
            return $this->responseSuccessMessage($result['message']);
        }
    }
    //举报评论
    public function reportComment() {
        $shopId = $this->request->get('shopid');
        $commentId = $this->request->get('commentid');
        $reportContent = $this->request->get('reportcontent');
        $result = CommentManagement::reportComment($shopId, $commentId, $reportContent);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        } else {
            return $this->responseSuccessMessage($result['message']);
        }
    }
    //举报列表
    public function reportList() {
        $shopId = $this->request->get('shopid');
        if($this->request->has('page')) {
            $page = $this->request->get('page');
        } else {
            $page = 1;
        }
        if($this->request->has('length')) {
            $length = $this->request->get('length');
        } else {
            $length = 20;
        }
        $result = CommentManagement::reportList($shopId, $page, $length);
        if($result['status'] == 'failed') {
            return $this->responseError($result['message']);
        } else {
            return $this->responseSuccessData($result['data']);
        }
    }
}